#pragma once

#include <iostream>

#include "Time.hpp"  //For getTime()
#include "Junk.hpp"  //For getNameInPath()

#define LOG_ENABLE

#ifdef _WIN32
#define __func__ __FUNCTION__
#endif

// Be sure to define LOG_ENABLE
#ifdef LOG_ENABLE
#define LOG(mode, ...) log(mode, __FILE__, __LINE__, __func__, __VA_ARGS__)
#else
#define LOG(mode, ...)
#endif

enum InfoLevel { Info, Warning, Error, FatalError };

// Every state of a log
const std::string logError[4] = { "[Info]", "[Warning]", "[Error]", 
								   "[Fatal Error]" };

inline void logRecursive() { std::cout << std::endl; }

// Loop recursively to handle every arguments
template <typename T, typename... Args>
void logRecursive(T first, const Args &... rest) {
	std::cout << first;
	logRecursive(rest...);
}

/// The logging function use in the macro
template <typename... Args>
void log(int m, const char *file, int line, const char *func,
	const Args &... args) {
	// Print  information for debugging purpose
	std::cout << getTime() << " " << logError[m] << " " << getNameInPath(file) << "(" << line
		<< ")"
		<< ", in " << func << " : ";

	// Start printing every argument
	logRecursive(args...);
}
